<template>
  <div class="app-container leftTable">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="样品名称" prop="ypmc">
        <el-input v-model="queryParams.ypmc" placeholder="请输入样品名称" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="生产批次" prop="scpc">
        <el-input v-model="queryParams.scpc" placeholder="请输入生产批次" clearable size="small" @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="报告日期" prop="bgrq">
        <el-date-picker :editable="false" clearable size="small" v-model="queryParams.bgrq" type="date" value-format="yyyy-MM-dd" placeholder="选择报告日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['Laboratory_microbe2:Laboratory_microbe2:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['Laboratory_microbe2:Laboratory_microbe2:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['Laboratory_microbe2:Laboratory_microbe2:remove']">删除</el-button>
      </el-col>
      <!--  <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['Laboratory_microbe2:Laboratory_microbe2:export']"
          >导出</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-s-check" size="mini" :disabled="multiple" @click="handleCheck" v-hasPermi="['Laboratory_microbe2:Laboratory_microbe2:check']">审核</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="Laboratory_microbe2List" @selection-change="handleSelectionChange" max-height="550">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" width="100px" />
      <el-table-column label="样品名称" align="center" prop="ypmc" min-width="120" />
      <el-table-column label="生产批次" align="center" prop="scpc" />
      <el-table-column label="检测日期" align="center" prop="jcrq" width="160">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jcrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="报告日期" align="center" prop="bgrq" width="160">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.bgrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <!--  <el-table-column
        label="检验项目"
        align="center"
        prop="jcxm"
        :formatter="laboratory_Microbe_jyxm_Format"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.jcxm }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="检验依据"
        align="center"
        prop="jcyj"
        :formatter="laboratory_Microbe_jcyj_Format"
      />
      <el-table-column
        label="菌落总数开始时间"
        align="center"
        prop="jlstart"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jlstart, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="菌落总数截止时间"
        align="center"
        prop="jlend"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jlend, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="霉菌-酵母菌开始时间"
        align="center"
        prop="mjjmstart"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.mjjmstart, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="霉菌-酵母菌截止时间"
        align="center"
        prop="mljmend"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.mljmend, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="大肠菌群"
        align="center"
        prop="dcqtstart"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dcqtstart, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="大肠菌群"
        align="center"
        prop="dcqtend"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dcqtend, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="大肠菌群"
        align="center"
        prop="dcstart"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dcstart, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="大肠菌群" align="center" prop="dcend" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dcend, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="铜绿" align="center" prop="tlstart" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tlstart, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="铜绿" align="center" prop="tlend" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tlend, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column> -->

      <el-table-column label="报表编号" align="center" prop="bbbh" width="200px" />
      <el-table-column label="检验人" align="center" prop="jyr" />
      <el-table-column label="审核人" align="center" prop="shrPerson" />
      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="250px">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="excelhandleView(scope.row)">导出</el-button>
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['Laboratory_microbe2:Laboratory_microbe2:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['Laboratory_microbe2:Laboratory_microbe2:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

    <!-- 添加或修改微生物检验原始记录（成品）对话框 -->
    <el-dialog v-myFullscreen fullscreen :title="title" :visible.sync="open" width="1300px" custom-class="myDialog">
      <TableHeader @nameChange="nameChange" :data="{
          mainTitle: '微生物检验原始记录（成品）',
          company: '青岛崂山矿泉水有限公司',
          code: form.bbbh,
        }" />
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="9">
            <el-form-item label="样品名称" prop="ypmc">
              <!-- <el-input
                v-model="form.ypmc"
                placeholder="请输入样品名称"
                :disabled="openDisabled"
              /> -->
              <Dialog @dialogChange="form.ypmc = $event.label" :echoValue="form.ypmc" parameter="rows" value="id" label="name" :multiple="true" search="name/code" url="/basic/productInfo/listSelect" :column="['产成品编号/code', '产成品名称/name']" placeholder="请选择内容" :axiosData="{ typeCode: 'YYTRKQS' }" :openDisabled="openDisabled" :pageSizes="[20,50,100,200,500]"/>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="生产批次" prop="scpc">
              <el-input v-model="form.scpc" placeholder="请输入生产批次" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="检测日期" prop="jcrq">
              <el-date-picker :editable="false" clearable v-model="form.jcrq" type="date" value-format="yyyy-MM-dd" placeholder="选择检测日期" :disabled="openDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="报告日期" prop="bgrq">
              <el-date-picker :editable="false" clearable v-model="form.bgrq" type="date" value-format="yyyy-MM-dd" placeholder="选择报告日期" :disabled="openDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="检验项目" prop="jcxm">
              <!-- <el-input v-model="form.jcxm" placeholder="请输入检验项目" :disabled="openDisabled" /> -->

              <el-checkbox-group v-model="form.jcxmsz">
                <el-checkbox v-for="dict in laboratory_Microbe_jyxm" :label="dict.dictLabel" :key="dict.dictValue" :disabled="openDisabled"></el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="检验依据" prop="jcyj">

              <el-checkbox-group v-model="form.jcyjsz">
                <el-checkbox v-for="dict in laboratory_Microbe_jcyj" :label="dict.dictLabel" :key="dict.dictValue" :disabled="openDisabled"></el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- 项目名称 -->
          <el-row>
            <el-col :span="2">
              <el-form-item label="项目名称" label-width="100%" label-position="left" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="菌落总数（CFU/ml)" label-width="100%" />
            </el-col>
            <el-col :span="3">
              <el-form-item label="霉菌(CFU/ml)" label-width="100%" />
            </el-col>
            <el-col :span="3">
              <el-form-item label="酵母菌(CFU/ml)" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="大肠菌群(其它饮用水)(CFU/ml)" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="大肠菌群(矿泉水)(MPN/100ml)" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="铜绿(矿泉水)(MPN/250ml)" label-width="100%" />
            </el-col>
          </el-row>
          <!-- 培养条件 -->
          <el-row>
            <el-col :span="2">
              <el-form-item label="培养条件" label-width="100%" label-position="left" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="36±1℃：48h±2h" label-width="100%" />
            </el-col>
            <el-col :span="6">
              <el-form-item label="28±1℃；5d" label-width="100%" class="center" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="平板计数:36±1℃;18～24 h" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="36±1℃;24 h" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item label="36±1℃；24～48 h" label-width="100%" />
            </el-col>
          </el-row>
          <!-- 开始时间 -->
          <el-row>
            <el-col :span="2">
              <el-form-item label="开始时间" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item prop="jlstart" label-width="3px">
                <el-date-picker @change="datePickerChange($event,'jlend',172800000)" :editable="false" clearable v-model="form.jlstart" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择菌落总数开始时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="mjjmstart" label-width="5px">
                <el-date-picker @change="datePickerChange($event,'mljmend',432000000)" :editable="false" clearable v-model="form.mjjmstart" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择霉菌-酵母菌开始时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="dcqtstart" label-width="5px">
                <el-date-picker @change="datePickerChange($event,'dcqtend',86400000)" :editable="false" clearable v-model="form.dcqtstart" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择大肠菌群开始时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="dcstart" label-width="5px">
                <el-date-picker @change="datePickerChange($event,'dcend',86400000)" :editable="false" clearable v-model="form.dcstart" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择大肠菌群开始时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="tlstart" label-width="5px">
                <el-date-picker @change="datePickerChange($event,'tlend',172800000)" :editable="false" clearable v-model="form.tlstart" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择铜绿开始时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- 结束时间 -->
          <el-row>
            <el-col :span="2">
              <el-form-item label="结束时间" label-width="100%" />
            </el-col>
            <el-col :span="4">
              <el-form-item prop="jlend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.jlend" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择菌落总数截止时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item prop="mljmend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.mljmend" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择霉菌-酵母菌截止时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="dcqtend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.dcqtend" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择大肠菌群结束时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="dcend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.dcend" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择大肠菌群结束时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="4">
              <el-form-item prop="tlend" label-width="5px">
                <el-date-picker :editable="false" clearable v-model="form.tlend" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择铜绿结束时间" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
            </el-col>
          </el-row>

          <!-- <el-col :span="12">
                <el-form-item label="菌落总数开始时间" prop="jlstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.jlstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择菌落总数开始时间" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="菌落总数截止时间" prop="jlend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.jlend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择菌落总数截止时间" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="霉菌-酵母菌开始时间" prop="mjjmstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.mjjmstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择霉菌-酵母菌开始时间" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="霉菌-酵母菌截止时间" prop="mljmend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.mljmend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择霉菌-酵母菌截止时间" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="大肠菌群" prop="dcqtstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.dcqtstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择大肠菌群" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="大肠菌群" prop="dcqtend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.dcqtend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择大肠菌群" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="大肠菌群" prop="dcstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.dcstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择大肠菌群" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="大肠菌群" prop="dcend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.dcend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择大肠菌群" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="铜绿" prop="tlstart">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.tlstart"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择铜绿" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="铜绿" prop="tlend">
                  <el-date-picker  :editable="false" clearable size="small"
                    v-model="form.tlend"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择铜绿" :disabled="openDisabled">
                  </el-date-picker>
                </el-form-item>
            </el-col> -->
          <!--
            <el-col :span="12">
                <el-form-item label="报表编号" prop="bbbh">
                  <el-input v-model="form.bbbh" placeholder="请输入报表编号" :disabled="openDisabled" />
                </el-form-item>
            </el-col>
            <el-col :span="12">
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" placeholder="请输入备注" :disabled="openDisabled" />
                </el-form-item>
            </el-col> -->
        </el-row>
        <br />
        <el-divider content-position="center">微生物检验原始记录（成品）子信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddQualityLabMicrobe2Sub1" :disabled="openDisabled">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteQualityLabMicrobe2Sub1" :disabled="openDisabled">删除</el-button>
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider>
        <el-table :data="qualityLabMicrobe2Sub1List" :row-class-name="rowQualityLabMicrobe2Sub1Index" border @selection-change="handleQualityLabMicrobe2Sub1SelectionChange" ref="qualityLabMicrobe2Sub1" :span-method="objectSpanMethod">
          <el-table-column type="selection" width="50" align="center" />
          <!-- <el-table-column label="序号" align="center" prop="index" width="50"/> -->
          <el-table-column align="center" label="项目名称" width="130">
            <el-table-column label="名称" align="center" prop="mc" min-width="320">
              <template slot-scope="scope">
                <!-- <div>
                <el-input placeholder="空白对照组" :disabled="true" />
              </div> -->
                <div>
                  <!-- <el-input
                  v-model="scope.row.mc"
                  placeholder="请输入名称"
                  :disabled="openDisabled"
                /> -->
                  <Dialog @dialogChange="qualityLabMicrobe2Sub1List[scope.$index].mc = $event.label" :echoValue="scope.row.mc" parameter="rows" value="id" label="name" :multiple="false" search="name/code" url="/basic/productInfo/listSelect" :column="['产成品编号/code', '产成品名称/name']" placeholder="请选择内容" :axiosData="{ typeCode: 'YYTRKQS' }" />
                </div>
              </template>
            </el-table-column>
            <el-table-column label="样品编号" align="center" prop="ypbh" min-width="260">
              <template slot-scope="scope">
                <!-- <div>
                <el-input
                  v-model="scope.row.ypbhdz"
                  placeholder="请输入样品编号"
                  :disabled="openDisabled"
                />
              </div> -->
                <div>
                  <el-input v-model="scope.row.ypbh" placeholder="请输入样品编号" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>

          <el-table-column align="center" label="菌落总数（CFU/ml)" width="280">
            <el-table-column align="center" label="平板1" prop="jlzs1" width="140">
              <template slot-scope="scope">
                <!-- <div>
                  <el-input
                    v-model="form.jlzsdz"
                    placeholder="菌落总数对照"
                    :disabled="openDisabled"
                  />
                </div> -->
                <div>
                  <el-input v-model="scope.row.jlzs1" placeholder="请输入菌落总数平板1" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
            <el-table-column align="center" label="平板2" prop="jlzs2" width="140">
              <template slot-scope="scope">
                <!-- <div>
                  <el-input :disabled="true" />
                </div> -->
                <div>
                  <el-input v-model="scope.row.jlzs2" placeholder="请输入菌落总数平板2" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column align="center" label="霉菌（CFU/ml)" width="130">
            <el-table-column align="center" label="平板1" prop="mjpb1" width="130">
              <template slot-scope="scope">
                <!-- <div>
                  <el-input
                    v-model="form.mjjmjdz"
                    placeholder="霉菌酵母菌对照"
                    :disabled="openDisabled"
                  />
                </div> -->
                <div>
                  <el-input v-model="scope.row.mjpb1" placeholder="请输入霉菌平板1" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>

          <el-table-column align="center" label="酵母菌（CFU/ml)" width="130">
            <el-table-column align="center" label="平板2" prop="jmjpb2" width="140">
              <template slot-scope="scope">
                <!--  <div>
                  <el-input :disabled="true" />
                </div> -->
                <div>
                  <el-input v-model="scope.row.jmjpb2" placeholder="请输入酵母菌平板2" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column align="center" label="大肠菌群（其他饮用水）(CFU/ml)" width="280">
            <el-table-column label="平板1" align="center" prop="dcjqpad1" width="140">
              <template slot-scope="scope">
                <!-- <div>
                  <el-input
                    v-model="form.dcjqdz"
                    placeholder="大肠菌群对照"
                    :disabled="openDisabled"
                  />
                </div> -->
                <div>
                  <el-input v-model="scope.row.dcjqpad1" placeholder="请输入大肠菌群" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
            <el-table-column label="平板2" align="center" prop="dcjqpad2" width="140">
              <template slot-scope="scope">
                <!--  <div>
                  <el-input :disabled="true" />
                </div> -->
                <div>
                  <el-input v-model="scope.row.dcjqpad2" placeholder="请输入大肠菌群" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>

          <el-table-column align="center" label="大肠菌群（矿泉水）(MPN/100ml)" width="260">
            <el-table-column align="center" label="10mL水样" prop="dcjpsy" width="260">
              <template slot-scope="scope">
                <!-- <div>
                  <el-input
                    v-model="form.dcjpsydz"
                    placeholder="10ml水样对照"
                    :disabled="openDisabled"
                  />
                </div> -->
                <div>
                  <el-input v-model="scope.row.dcjpsy" placeholder="请输入大肠菌群" :disabled="openDisabled" />
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column align="center" label="铜绿(CFU/250ml)" width="720">
            <el-table-column align="center" label="蓝/绿色" prop="tlbluegreen" width="180">
              <template slot-scope="scope">
                <el-select v-model="scope.row.tlbluegreen" placeholder="请选择铜绿" style="width: 100%" :disabled="openDisabled">
                  <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column align="center" label="产荧光（非蓝/绿）" prop="tlnogluegreen" width="180">
              <template slot-scope="scope">
                <el-select v-model="scope.row.tlnogluegreen" placeholder="请选择铜绿" style="width: 100%" :disabled="openDisabled">
                  <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column align="center" label="红褐色" prop="tlred" width="180">
              <template slot-scope="scope">
                <el-select v-model="scope.row.tlred" placeholder="请选择铜绿" style="width: 100%" :disabled="openDisabled">
                  <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
                </el-select>
              </template>
            </el-table-column>
            <el-table-column align="center" label="其他形态" prop="tlother" width="180">
              <template slot-scope="scope">
                <el-select v-model="scope.row.tlother" placeholder="请选择铜绿" style="width: 100%" :disabled="openDisabled">
                  <el-option v-for="dict in laboratory_Microbe_tl" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue"></el-option>
                </el-select>
              </template>
            </el-table-column>
          </el-table-column>
          <!-- <el-table-column label="报表编号" prop="bbbh">
            <template slot-scope="scope">
                <el-input v-model="scope.row.bbbh" placeholder="请输入报表编号" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" placeholder="请输入备注" :disabled="openDisabled"/>
            </template>
          </el-table-column> -->
        </el-table>

        <!-- 审核 检验 -->
        <el-row>
          <el-col :span="12">
            <el-form-item label="审核人" prop="shrPerson">
              <el-input v-model="form.shrPerson" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="检验人" prop="jyr">
              <el-select v-model="form.jyr" filterable allow-create placeholder="请选择检验人" style="width: 100%" :disabled="openDisabled">
                <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName" :disabled="openDisabled"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <!-- <el-divider content-position="center">微生物检验原始记录（成品）子2信息</el-divider>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAddQualityLabMicrobe2Sub2" :disabled="openDisabled">添加</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteQualityLabMicrobe2Sub2" :disabled="openDisabled">删除</el-button>
          </el-col>
        </el-row>
        <el-table :data="qualityLabMicrobe2Sub2List" :row-class-name="rowQualityLabMicrobe2Sub2Index" @selection-change="handleQualityLabMicrobe2Sub2SelectionChange" ref="qualityLabMicrobe2Sub2">
          <el-table-column type="selection" width="50" align="center" />
          <el-table-column label="序号" align="center" prop="index" width="50"/>
          <el-table-column label="样品名称" prop="ypmc">
            <template slot-scope="scope">
                <el-input v-model="scope.row.ypmc" placeholder="请输入样品名称" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="样品编号" prop="ypbh">
            <template slot-scope="scope">
                <el-input v-model="scope.row.ypbh" placeholder="请输入样品编号" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="菌落总数" prop="jlzs">
            <template slot-scope="scope">
                <el-input v-model="scope.row.jlzs" placeholder="请输入菌落总数" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="霉菌-酵母菌" prop="mjjmj">
            <template slot-scope="scope">
                <el-input v-model="scope.row.mjjmj" placeholder="请输入霉菌-酵母菌" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="大肠菌群" prop="dcjqother">
            <template slot-scope="scope">
                <el-input v-model="scope.row.dcjqother" placeholder="请输入大肠菌群" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="大肠菌群" prop="dcjqkq">
            <template slot-scope="scope">
                <el-input v-model="scope.row.dcjqkq" placeholder="请输入大肠菌群" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="铜绿" prop="tlkq">
            <template slot-scope="scope">
                <el-input v-model="scope.row.tlkq" placeholder="请输入铜绿" :disabled="openDisabled"/>
            </template>
          </el-table-column>
          <el-table-column label="备注" prop="remark">
            <template slot-scope="scope">
                <el-input v-model="scope.row.remark" placeholder="请输入备注" :disabled="openDisabled"/>
            </template>
          </el-table-column>
        </el-table> -->
      </el-form>
      <div slot="footer" class="dialog-footer" v-if="!openDisabled">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listLaboratory_microbe2,
  getLaboratory_microbe2,
  delLaboratory_microbe2,
  addLaboratory_microbe2,
  updateLaboratory_microbe2,
  checkLaboratory_microbe2,
} from "@/api/quality/laboratory/Laboratory_microbe2";
import { getInfo } from "@/api/login";
import { listUser } from "@/api/system/user";

export default {
  name: "Laboratory_microbe2",
  data() {
    return {
      //弹窗是否禁止编辑
      openDisabled: true,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedQualityLabMicrobe2Sub1: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 微生物检验原始记录（成品）表格数据
      Laboratory_microbe2List: [],
      // 微生物检验原始记录（成品）子1表格数据
      qualityLabMicrobe2Sub1List: [],
      // 微生物检验原始记录（成品）子2表格数据
      qualityLabMicrobe2Sub2List: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 50,
        ypmc: null,
        scpc: null,
        bgrq: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      laboratory_Microbe_jyxm: "",
      laboratory_Microbe_jcyj: "",
      /* 当前用户名 */
      nickName: "",
      userList: [],
    };
  },
  created() {
    this.dict();
    this.getList();
    this.queryUserList();
  },
  methods: {
    dict() {
      this.getDicts("laboratory_Microbe_jyxm").then((response) => {
        this.laboratory_Microbe_jyxm = response.data;
      });
      this.getDicts("laboratory_Microbe_jcyj").then((response) => {
        this.laboratory_Microbe_jcyj = response.data;
      });
      this.getDicts("laboratory_Microbe_tl").then((response) => {
        this.laboratory_Microbe_tl = response.data;
      });
    },
    /** 查询微生物检验原始记录（成品）列表 */
    getList() {
      this.loading = true;
      listLaboratory_microbe2(this.queryParams).then((response) => {
        this.Laboratory_microbe2List = response.rows;
        this.Laboratory_microbe2List = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /* 合并列 */
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (rowIndex === 0) {
        // console.log(rowIndex);
        // console.log(columnIndex);
        if (columnIndex === 3) {
          return [1, 2];
        }
        if (columnIndex === 4) {
          return [0, 0];
        }
        if (columnIndex === 5) {
          return [1, 2];
        }
        if (columnIndex === 6) {
          return [0, 0];
        }
        if (columnIndex === 7) {
          return [1, 2];
        }
        if (columnIndex === 8) {
          return [0, 0];
        }
        if (columnIndex === 10) {
          return [1, 4];
        }
        if (columnIndex === 11) {
          return [0, 0];
        }
        if (columnIndex === 12) {
          return [0, 0];
        }
        if (columnIndex === 13) {
          return [0, 0];
        }
      }
      // return {
      //       rowspan: 2,
      //       colspan: 1
      //     };

      // if (columnIndex === 0) {
      // if (rowIndex % 2 === 0) {
      //   return {
      //     rowspan: 2,
      //     colspan: 1
      //   };
      // } else {
      //   return {
      //     rowspan: 0,
      //     colspan: 0
      //   };
      // }
      // if (columnIndex === 0) {
      //   const _row = this.flitterData(this.qualityProdHygieneSubList).one[rowIndex];
      //   const _col = _row > 0 ? 1 : 0;
      //   return {
      //     rowspan: _row,
      //     colspan: _col,
      //   };
      // }
      // }
    },
    // 故障类型字典翻译
    laboratory_Microbe_jyxm_Format(row, column) {
      return this.selectDictLabel(this.laboratory_Microbe_jyxm, row.jyxm);
    },
    laboratory_Microbe_jcyj_Format(row, column) {
      return this.selectDictLabel(this.laboratory_Microbe_jcyj, row.jcyj);
    },
    laboratory_Microbe_tl_Format(row, column) {
      return this.selectDictLabel(this.laboratory_Microbe_tl, row.tl);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        ypmc: null,
        scpc: null,
        jcrq: null,
        bgrq: null,
        jcxm: null,
        jcxmsz: [],
        jcyj: null,
        jcyjsz: [],
        jlstart: null,
        jlend: null,
        mjjmstart: null,
        mljmend: null,
        dcqtstart: null,
        dcqtend: null,
        dcstart: null,
        dcend: null,
        tlstart: null,
        tlend: null,
        shrPerson: null,
        jyr: this.nickName,
        bbbh: "LK-QF-LS1-10-015-11-05",
        remark: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null,
      };
      this.qualityLabMicrobe2Sub1List = [];
      this.qualityLabMicrobe2Sub2List = [];
      this.resetForm("form");
    },
    datePickerChange(e, key,num) {
        var time = new Date(e).getTime() + num;
        this.$set(this.form,key,this.parseTime(time, '{y}-{m}-{d} {h}:{i}:{s}'))
      },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.dict();
      this.reset();
      this.openDisabled = false;
      this.open = true;
      this.title = "添加微生物检验原始记录（成品）";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.dict();
      this.reset();
      this.openDisabled = false;
      const id = row.id || this.ids;
      getLaboratory_microbe2(id).then((response) => {
        this.form = response.data;
        this.qualityLabMicrobe2Sub1List =
          response.data.qualityLabMicrobe2Sub1List;
        this.qualityLabMicrobe2Sub2List =
          response.data.qualityLabMicrobe2Sub2List;
        this.open = true;
        this.title = "修改微生物检验原始记录（成品）";
      });
    },
    /** 查看按钮 */
    handleView(row) {
      this.dict();
      this.reset();
      this.openDisabled = true;
      const id = row.id || this.ids;
      getLaboratory_microbe2(id).then((response) => {
        this.form = response.data;
        this.qualityLabMicrobe2Sub1List =
          response.data.qualityLabMicrobe2Sub1List;
        this.qualityLabMicrobe2Sub2List =
          response.data.qualityLabMicrobe2Sub2List;
        this.open = true;
        this.title = "查看微生物检验原始记录（成品）";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.form.qualityLabMicrobe2Sub1List =
            this.qualityLabMicrobe2Sub1List;
          this.form.qualityLabMicrobe2Sub2List =
            this.qualityLabMicrobe2Sub2List;
          /**打开遮罩层*/
          const rLoading = this.openLoading();
          if (this.form.id != null) {
            updateLaboratory_microbe2(this.form)
              .then((response) => {
                /**成功后执行关闭遮罩层*/
                rLoading.close();
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              })
              .catch((error) => {
                /**请求异常后执行关闭遮罩层*/
                rLoading.close();
              });
          } else {
            addLaboratory_microbe2(this.form)
              .then((response) => {
                /**成功后执行关闭遮罩层*/
                rLoading.close();
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              })
              .catch((error) => {
                /**请求异常后执行关闭遮罩层*/
                rLoading.close();
              });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm(
        '是否确认删除微生物检验原始记录（成品）编号为"' + ids + '"的数据项?',
        "警告",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(function () {
          return delLaboratory_microbe2(ids);
        })
        .then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 微生物检验原始记录（成品）子1序号 */
    rowQualityLabMicrobe2Sub1Index({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 微生物检验原始记录（成品）子1添加按钮操作 */
    handleAddQualityLabMicrobe2Sub1() {
      let obj = {};
      obj.mc = "";
      obj.ypbh = "";
      obj.jlzs1 = "0";
      obj.jlzs2 = "0";
      obj.mjpb1 = "0";
      obj.jmjpb2 = "0";
      obj.dcjqpad1 = "空";
      obj.dcjqpad2 = "空";
      obj.dcjpsy = "0";
      obj.tlbluegreen = this.laboratory_Microbe_tl[0].dictValue;
      obj.tlnogluegreen = this.laboratory_Microbe_tl[0].dictValue;
      obj.tlred = this.laboratory_Microbe_tl[0].dictValue;
      obj.tlother = this.laboratory_Microbe_tl[0].dictValue;
      obj.bbbh = "";
      obj.remark = "";
      //对照组
      obj.ypbhdz = "0";
      obj.jlzsdz = "";
      obj.mjjmjdz = "";
      obj.dcjqdz = "空";
      obj.dcjpsydz = "空";
      this.qualityLabMicrobe2Sub1List.push(obj);
    },
    /** 微生物检验原始记录（成品）子1删除按钮操作 */
    handleDeleteQualityLabMicrobe2Sub1() {
      if (this.checkedQualityLabMicrobe2Sub1.length == 0) {
        this.$alert(
          "请先选择要删除的微生物检验原始记录（成品）子1数据",
          "提示",
          { confirmButtonText: "确定" }
        );
      } else {
        this.qualityLabMicrobe2Sub1List.splice(
          this.checkedQualityLabMicrobe2Sub1[0].index - 1,
          1
        );
      }
    },
    /** 微生物检验原始记录（成品）子2序号 */
    rowQualityLabMicrobe2Sub2Index({ row, rowIndex }) {
      row.index = rowIndex + 1;
    },
    /** 微生物检验原始记录（成品）子2添加按钮操作 */
    handleAddQualityLabMicrobe2Sub2() {
      let obj = {};
      obj.ypmc = "";
      obj.ypbh = "";
      obj.jlzs = "";
      obj.mjjmj = "";
      obj.dcjqother = "";
      obj.dcjqkq = "";
      obj.tlkq = "";
      obj.remark = "";
      this.qualityLabMicrobe2Sub2List.push(obj);
    },
    /** 微生物检验原始记录（成品）子2删除按钮操作 */
    handleDeleteQualityLabMicrobe2Sub2() {
      if (this.checkedQualityLabMicrobe2Sub2.length == 0) {
        this.$alert(
          "请先选择要删除的微生物检验原始记录（成品）子2数据",
          "提示",
          { confirmButtonText: "确定" }
        );
      } else {
        this.qualityLabMicrobe2Sub2List.splice(
          this.checkedQualityLabMicrobe2Sub2[0].index - 1,
          1
        );
      }
    },
    /** 单选框选中数据 */
    handleQualityLabMicrobe2Sub1SelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.qualityLabMicrobe2Sub1.clearSelection();
        this.$refs.qualityLabMicrobe2Sub1.toggleRowSelection(selection.pop());
      } else {
        this.checkedQualityLabMicrobe2Sub1 = selection;
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "Laboratory_microbe2/Laboratory_microbe2/export",
        {
          ...this.queryParams,
        },
        `Laboratory_microbe2_Laboratory_microbe2.xlsx`
      );
    },
    excelhandleView(row) {
      this.download(
        "Laboratory/Laboratory_microbe2/exportexcel?id=" + row.id,
        {
          ...this.queryParams,
        },
        "微生物检验原始记录（成品）" + this.parseTime(new Date()) + ".xlsx"
      );
    },
    //接收编号
    nameChange(e) {
      this.form.bbbh = e;
    },
    /** 审核按钮操作 */
    handleCheck(row) {
      /* 审核 */
      this.ids.forEach((id) => {
        getLaboratory_microbe2(id).then((response) => {
          if (
            response.data.shrPerson != null &&
            response.data.shrPerson != ""
          ) {
            this.msgError(
              '编号为"' + id + '"的数据项已审核完成，无需重复审核！'
            );
          } else {
            let obj = {};
            obj.id = id;
            obj.shrPerson = this.nickName;
            obj.qualityLabMicrobe2Sub1List = this.qualityLabMicrobe2Sub1List;
            obj.qualityLabMicrobe2Sub2List = this.qualityLabMicrobe2Sub2List;
            /* 修改 */
            checkLaboratory_microbe2(obj).then((response) => {
              this.msgSuccess('编号为"' + id + '"的数据项审核成功！');
              this.getList();
            });
          }
        });
      });
    },
    /* 查询用户列表 */
    queryUserList() {
      listUser().then((response) => {
        this.userList = response.rows;
      });
      getInfo().then((response) => {
        this.nickName = response.user.nickName;
      });
    },
  },
};
</script>
<style>
.leftTable .el-form-item__label {
  text-align: left !important;
}
.leftTable .center .el-form-item__label {
  text-align: center !important;
}
</style>